package com.ly.system.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ly.system.system.bean.entity.SysPermission;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * 菜单权限-mapper
 */
public interface SysPermissionMapper extends BaseMapper<SysPermission> {

    /**
     * 列表
     *
     * @param entity
     * @return
     */
    List<SysPermission> getList(@Param("dto") SysPermission entity);

    /**
     * 根据用户查询用户权限
     *
     * @param userId 用户ID
     * @return List<SysPermission>
     */
    List<SysPermission> getAuthByUserId(@Param("userId") String userId);

    /**
     * 修改菜单状态字段： 是否子节点
     *
     * @param id   菜单id
     * @param leaf 叶子节点
     * @return int
     */
    @Update("update sys_permission set is_leaf=#{leaf} where id = #{id}")
    int setMenuLeaf(@Param("id") String id, @Param("leaf") int leaf);
}
